def perebor(n):
    global possible, res, counter
    for i in range(a - n):
        res.append(possible[i])
        possible.pop(i)
        if len(res) == a:
            print(''.join([str(i)  for i in res]))
            counter += 1
        elif len(res) < a:
            perebor(n + 1)
        possible.append(res[-1])
        possible.sort()
        res.pop(-1)

a = int(input())
possible = [i for i in range(1, a + 1)]
res = []
counter = 0
perebor(0)
#print(counter)